package com.anche.cywebnew.Service.configManager.impl;

import com.anche.cywebnew.DAO.configManager.SysOptionMapper;
import com.anche.cywebnew.Pojo.configManager.SysOptions;
import com.anche.cywebnew.Pojo.systemManager.TerminalInfo;
import com.anche.cywebnew.Service.configManager.SysOptionService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class SysOptionServiceImpl implements SysOptionService {

    @Autowired
    private SysOptionMapper sysOptionMapper;

    @Override
    public Page<SysOptions> getSysOptionPager(Integer page, Integer limit, SysOptions sysOptions) {
        Page<SysOptions> page1 = PageHelper.startPage(page, limit);
        sysOptionMapper.selectSysOptionsList(sysOptions);
        return page1;
    }

    @Override
    public List<SysOptions> getSysOptionList(SysOptions sysOptions) {
        return sysOptionMapper.selectSysOptionsList(sysOptions);
    }

    @Override
    public List<String> getOptionKindList() {
        return sysOptionMapper.selectDistinctOptionKind();
    }

    @Override
    public void addSysOption(SysOptions sysOptions) {
        String uuid = UUID.randomUUID().toString().replaceAll("-","");
        sysOptions.setId(uuid);
        sysOptions.setIs_stop("1");
        sysOptionMapper.insertSysOptions(sysOptions);
    }

    @Override
    public void setSysOption(SysOptions sysOptions) {
        sysOptionMapper.updateById(sysOptions);
    }

    @Override
    public void delSysOption(String id) {
        sysOptionMapper.deleteById(id);
    }
}
